import { createRouter, createWebHashHistory } from "vue-router";
import TopCategoryPage from "@/views/categroy/TopCategoryPage";
import SubCategoryPage from "@/views/categroy/SubCategoryPage";
const LoginPage = () => import("@/views/login/LoginPage");
const homePage = () => import("@/views/home/homePage");
const GoodsDetailPage = () => import("@/views/goods/GoodsDetailPage");
const LoginCallbackPage = () => import("@/views/login/LoginCallbackPage");

const routes = [
  {
    path: "/",
    component: homePage,
  },
  {
    path: "/category/:id",
    component: TopCategoryPage,
  },
  {
    path: "/category/sub/:id",
    component: SubCategoryPage,
  },
  {
    path: "/goods/:id",
    component: GoodsDetailPage,
  },
  {
    path: "/login",
    component: LoginPage,
  },
  {
    path: "/login/callback",
    component: LoginCallbackPage,
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  // 路由切换后让页面回到顶部
  scrollBehavior() {
    return {
      top: 0,
    };
  },
  routes,
});

export default router;
